Proj: デバッグ情報を分離して最適化をしやすくする
デバッグ情報を分離するにはobjcopyを使う
デバッグ情報を含む、a.out.debug という名前の別のデバッグファイルを作成する
$ objcopy --only-keep-debug executable_file executable_file.debug
実行ファイル(executable_file)からデバッグ情報をストリップ(除去)する
$ objcopy --strip-unneeded executable_file
2つのファイル間にリンクを作成
$ objcopy --add-gnu-debuglink=executable_file.debug executable_file
実行例
$ objcopy --only-keep-debug a.out a.out.debug
$ objcopy --strip-debug a.out
$ objcopy --add-gnu-debuglink=a.out.debug a.out
関連
デバッグ情報を別ファイルに切り出す
debuginfo
Makefile
扱いやすそうなMakefileテンプレート
gccの最適化の仕様
参考
『CおよびC++のコンパイラ・オプション強化ガイド』 - The Linux Foundation
別のデバッグファイルの使用 (Oracle Solaris Studio 12.2: dbx コマンドによるデバッグ)